from django.shortcuts import render_to_response
from django.http import HttpResponse
from computermanage.models import *
import datetime
from datetime import *
from time import gmtime, strftime

def main(request):
    return render_to_response('search_form.html')

def search(request):
    if request.GET ['q'] == "":
        message = 'Who are u.Cat ?'   
    else:
        message = 'You is : %s cat' % request.GET['q']
    return HttpResponse(message)

def inform(request):
    return render_to_response('inform_request.html')
def r_inform(request):
    try:
        upst = Computer.objects.get(comp_ID='%s'%request.GET['comid'])
        message = 'You inform for : %s ' % request.GET['comid']
        com = Request(
            request_Date = '%s' % date.today(),
            request_Time = '%s' % strftime("%H:%M:%S"),
            request_Com_ID = '%s' % request.GET['comid'],
            requset_ComProb = '%s' % request.GET['problem'],
            request_Status = 'new',)
        com.request_ID += 1
        com.save()

        upst.comp_Status = 'offline'
        upst.save()
    except Computer.DoesNotExist:
        message = 'No your computer in database'        
    return HttpResponse(message)


def login(request):
    return render_to_response('login.html')
def r_login(request):
    return HttpResponse('cat')
    











